<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="${request.contextPath}/"/>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,minimum-scale=1.0">
    <title>漠河智慧社区</title>
    <link href="Content/wechat/css/reset.css" rel="stylesheet" type="text/css">
    <!--签到-->
    <link href="Content/wechat/css/public.css" rel="stylesheet" type="text/css">
    <link href="Content/wechat/css/signin.css" rel="stylesheet" type="text/css">
    <!--banner-->
    <link href="Content/wechat/css/amazeui.min.css" rel="stylesheet" type="text/css">
    <script src="Content/wechat/js/jquery.min.js"></script>
    <!--字体缩放-->
    <script src="Content/wechat/js/ziti.js"></script>
    <!--end 字体缩放-->
</head>
<body>
<!--header-->
<div class="top flex flex-align-end flex-pack-center flex-warp">
    <div class="out-1 flex flex-align-center flex-pack-center" id="signIn">
        <div class="out-2 flex flex-align-center flex-pack-center">
            <div class="signBtn">
                <strong id="sign-txt">签到</strong>
                <span>总计签到<em id="sign-count">0</em>天</span>
            </div>
        </div>
    </div>
</div>
<div class="tips" id="numtips" style="display: none">今天已签到，已成功获得${num!}积分</div>
<div class="Calendar">
    <div id="toyear" class="flex flex-pack-center">
        <div id="idCalendarPre">&lt;</div>
        <div class="year-month">
            <span id="idCalendarYear">2018</span>年<span id="idCalendarMonth">6</span>月
        </div>
        <div id="idCalendarNext">&gt;</div>
    </div>
    <table border="1px" cellpadding="0" cellspacing="0">
        <thead>
        <tr class="tou">
            <td>日</td>
            <td>一</td>
            <td>二</td>
            <td>三</td>
            <td>四</td>
            <td>五</td>
            <td>六</td>
        </tr>
        </thead>
        <tbody id="idCalendar">
        </tbody>
    </table>
</div>
<script type="text/javascript" src="Content/wechat/js/rili.js"></script>
<script language="JavaScript">
    var isSign = false;
    var myday = new Array(${dateArr!}); //已签到的数组
    			// myday[0] = "1565677622"
    //			myday[1] = "1528387200"
    //			myday[2] = "1525708800"

    var cale = new Calendar("idCalendar", {
        qdDay: myday,
        onToday: function(o) {
            o.className = "onToday";
        },
        onSignIn: function (){
            $$("sign-txt").innerHTML = '已签到';

        },
        onFinish: function() {
            $$("sign-count").innerHTML = myday.length //已签到次数
            $$("idCalendarYear").innerHTML = this.Year;
            $$("idCalendarMonth").innerHTML = this.Month; //表头年份

        }
    });
    $$("idCalendarPre").onclick = function() {
        cale.PreMonth();
    }
    $$("idCalendarNext").onclick = function() {
        cale.NextMonth();
    }
    //添加今天签到
    $$("signIn").onclick = function() {
        if(isSign == false) {
            var res = cale.SignIn();
            if(res == '1') {
                $$("sign-txt").innerHTML = '已签到';
                $$("sign-count").innerHTML = parseInt($$("sign-count").innerHTML) + 1;
                isSign = true;
                $("#numtips").attr("style","display: ");
                addSignIn();
            } else if (res == '2'){
                $$("sign-txt").innerHTML = '已签到';
                alert('今天已经签到了')
            }
        } else {
            alert('今天已经签到了')
        }

    }


    function addSignIn(){
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/wechat/forum/signin/add",//url
            data: {num:${num!}},
            success: function (result) {
                console.log(result);//打印服务端返回的数据(调试用)
                if (result.code == 200) {

                } else {
                    alert("请稍后再试");
                }
            },
            error: function () {
                alert("异常！");
            }
        });
    }
</script>

</body>
